/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;


import com.taobao.wolfwolf.hibernate.dao.ColorDao;
import com.taobao.wolfwolf.hibernate.pojo.Color;

/**
 * @author Tux
 *
 * 创建时间: 2011-4-29 下午08:14:09
 */
@SuppressWarnings("unchecked")
public class ColorDaoImpl extends BaseDaoImpl implements ColorDao {

	public Color findById(int id) throws Exception {
		return (Color) getHibernateTemplate().get(Color.class, id);
	}
	
	public List<Color> findByName(String name) throws Exception {
		return super.findByProperty(Color.class, "name", name);
	}

	public List<Color> findAll() throws Exception {
		return getHibernateTemplate().find("from Color");
	}

	public long getTotal() throws Exception {
		return super.countByCriteria(Color.class);
	}

	public List<Color> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Color.class, page, limit);
	}

	@Override
	public Integer getMaxId() throws Exception {
		return (Integer) getSession().createQuery("select max(id) from Color").uniqueResult();
	}
}
